package com.study.kafka.basic;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.Properties;

/**
 * Description:
 * User: tan
 * DateTime: 2017/12/28 13:59
 */
public class ProducerDemo {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "pandaol.picp.io:9088");
        props.put("key.serializer", "org.apache.kafka.common.serialization.LongSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("acks", "-1");
        props.put("retries", "3");

        KafkaProducer<Long, String> producer = new KafkaProducer<>(props);
        //producer.beginTransaction();
        //保存cmd到本地文件  发送cmd到broker应该是一个事务

        ProducerRecord<Long, String> record = new ProducerRecord<Long, String>("eee",10L, "lll");
        producer.send(record);
    }
}
